--- title: Calibration Procedure keywords: fastai sidebar: home_sidebar summary: "Every OpenHSI camera is unique and requires calibration before use. This module provides the abstractions to create the calibration data which are then used in operation. " description: "Every OpenHSI camera is unique and requires calibration before use. This module provides the abstractions to create the calibration data which are then used in operation. " nb_path: "nbs/05_calibrate.ipynb" ---
{% include tip.html content='This module can be imported using from openhsi.calibrate import *' %}
There are a few ways to create a SettingsBuilder class that words for your custom camera. (They involve Python metaclasses and mixins)
For example, you can then create a SettingsBuilder class that works for your custom camera by doing one of the following.
{% include note.html content='Below we use the ’SimulatedCamera’ class. When calibrating a real camera you would replace SimulatedCamera with your camera class.' %}
SettingsBuilder = create_settings_builder("SettingsBuilder",SimulatedCamera)
# using Metaclasses
SettingsBuilder = SettingsBuilderMetaclass("SettingsBuilder",SimulatedCamera,{})
# initialising
sb = SettingsBuilder(json_path="assets/cam_settings.json",
pkl_path="assets/cam_calibration.pkl")
class CalibrateOpenHSI(SettingsBuilderMixin, SimulatedCamera):
pass
sb = CalibrateOpenHSI(mode="flat",json_path="assets/cam_settings.json", pkl_path="assets/cam_calibration.pkl")
hvimg=sb.retake_flat_field(show=True)
hvimg.opts(width=400,height=400)
print(sb.calibration["flat_field_pic"].max())
hvimg
sb.update_row_minmax()
sb.update_resolution()
sb.mode_change("HgAr")
hvimg=sb.retake_HgAr(show=True, nframes=1)
hvimg.opts(width=400,height=400)
print(sb.calibration["HgAr_pic"].max())
hvimg